<template>

  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="医师名称" prop="doctorName">
        <el-input
            v-model="queryParams.departmentName"
            placeholder="请输入医师名称"
            clearable
            @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>


  <el-table v-loading="loading" :data="tableList" @selection-change="handleSelectionChange">
    <el-table-column label="序号" align="center" prop="id" />
    <el-table-column prop="userId" label="用户ID" align="center" />
    <el-table-column prop="rankOfPhysician" label="医师等级" align="center" />
    <el-table-column prop="doctorName" label="医师姓名" align="center" />
    <el-table-column prop="ageLimit" label="年限" align="center" />
    <el-table-column label="医师资格证书" prop="doctorsCertificate" width="180">
        <template  #default="scope">
          <el-image :src="scope.row.certificate" alt="图片损坏" width="50px" height="50px"></el-image>
        </template>
    </el-table-column>
    <el-table-column label="医师资格证书" prop="medicalPracticeCertificate" width="180">
      <template  #default="scope">
        <el-image :src="scope.row.practice" alt="图片损坏" width="50px" height="50px"></el-image>
      </template>
    </el-table-column>
    <el-table-column prop="numConsultations" label="问诊次数" align="center" />
    <el-table-column prop="grossincomeAmount" label="总收入金额" align="center" />
<!--    <el-table-column prop="degree" label="好评度" align="center" />-->
    <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
      <template #default="scope">
        <el-button link type="primary"  @click="access(scope.row.rankOfPhysician)">进入</el-button>
      </template>
    </el-table-column>
  </el-table>
    <pagination
        v-show="total>0"
        :total="total"
        v-model:page="queryParams.pageNum"
        v-model:limit="queryParams.pageSize"
        @pagination="getList"
    />
  </div>
</template>

<script setup name="manage">
import {listDoctor} from "@/api/manage/AdministrativeOffice.js";
import {useRoute, useRouter} from "vue-router";
import { reactive, ref } from 'vue'


const { proxy } = getCurrentInstance();

const tableList = ref(true);
const open = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);


const multiple = ref(true);
const total = ref(0);
const title = ref("");
const route = useRoute();
const router = useRouter();

let  rankOfPhysician= route.query.rankOfPhysician;
const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    id: null,
    userId: null,
    rankOf: null,
    doctorName: null,
    ageLimit: null,
    doctorsCertificate: null,
    medicalPracticeCertificate: null,
    grossincomeAmount: null,

  },
  rules: {
  }
});

const { form,rules,queryParams } = toRefs(data)


/** 查询医师列表 */
function getList() {
  loading.value = true;

  listDoctor(rankOfPhysician).then(response => {
    console.log(response)
    tableList.value= response.data;
    total.value = response.data.total;
    loading.value = false;
  });
}

function access(id){
  router.push({path:'/manage/information',query:{id:id}});
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  handleQuery();
}

// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.departmentId);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}



getList();
</script>

